<%@page contentType="text/html" pageEncoding="UTF-8"%>

<%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<%@taglib prefix="a4j" uri="http://richfaces.org/a4j"%>
<%@taglib prefix="rich" uri="http://richfaces.org/rich"%>
<f:subview id="step3">
    <h:panelGrid columns="4">
        <f:facet name="header">
            <h:outputText value="#{msg.references} 3/5" />
        </f:facet>

        <h:outputText value="#{msg.mother}" id="madre-l"/>
        <h:inputText id="madre" value="#{convalidaPaziente.madre}" styleClass="madre"  >
            <f:validateLongRange minimum="0" />
        </h:inputText>
        <rich:suggestionbox height="200" width="200"
                            suggestionAction="#{convalidaPaziente.autocompleteMadre}" var="res"
                            for="madre" id="madre-s"
                            fetchValue="#{res.id}">
            <h:column>
                <h:outputText value="#{res.nome} #{res.cognome}" />                                    
            </h:column>
        </rich:suggestionbox>
        <img src="/PortaleVisite/resources/img/cancel.png" onclick="disMadre()" style="height: 13px" />




        <h:outputText value="#{msg.father}" id="padre-l"/>
        <h:inputText id="padre" value="#{convalidaPaziente.padre}" styleClass="padre" >
            <f:validateLongRange minimum="0" />
        </h:inputText>
        <rich:suggestionbox height="200" width="200"
                            suggestionAction="#{convalidaPaziente.autocompletePadre}" var="res"
                            for="padre" id="padre-s"
                            fetchValue="#{res.id}">
            <h:column>
                <h:outputText value="#{res.nome} #{res.cognome}" />                                    
            </h:column>
        </rich:suggestionbox>
        <img src="/PortaleVisite/resources/img/cancel.png" onclick="disPadre()" style="height: 13px" />
        


        <h:outputText value="#{msg.major}" id="capo-l"/>
        <h:inputText id="capov" value="#{convalidaPaziente.id_capovillaggio}" required="true" styleClass="capov"
                     requiredMessage="#{msg.required_text_error}"
                     validatorMessage="#{msg.required_text_error}"
                     >
            <f:validateLongRange minimum="1" />
        </h:inputText>
        <rich:suggestionbox height="200" width="200"
                            suggestionAction="#{convalidaPaziente.autocompleteCapovillaggio}" var="res"
                            for="capov" id="capov-s"
                            fetchValue="#{res.id}">
            <h:column>
                <h:outputText value="#{res.nome} #{res.cognome}" />                                    
            </h:column>
        </rich:suggestionbox>
        <rich:message for="capov" errorClass="error-message"/>



        <h:outputText value="#{msg.medics}" id="medico-l"/>
        <h:inputText id="medico" value="#{convalidaPaziente.medico}" required="true" styleClass="capov"
                     requiredMessage="#{msg.required_text_error}"
                     validatorMessage="#{msg.required_text_error}">
            <f:validateLongRange minimum="1" />
        </h:inputText>
        <rich:suggestionbox height="200" width="200"
                            suggestionAction="#{convalidaPaziente.autocompleteMedico}" var="res" 
                            for="medico" id="medico-s"
                            fetchValue="#{res.id}">
            <h:column>
                <h:outputText value="#{res.nome} #{res.cognome}" />                                    
            </h:column>
        </rich:suggestionbox>
        <rich:message for="medico" errorClass="error-message" />

    </h:panelGrid>
    <h:commandLink action="prev" >
           <img src="/PortaleVisite/resources/img/left.png" style="width: 50px" />
        </h:commandLink> 
        <h:commandLink action="next" >
           <img src="/PortaleVisite/resources/img/right.png" style="width: 50px" />
        </h:commandLink>  

    <script>
        function disMadre(){
            var dis = j(".madre").attr("disabled")
            if(dis == null){
                j(".madre").val("0");
                j(".madre").attr("disabled", "disabled");
            }
            else{
                j(".madre").removeAttr("disabled");
            }
        }
        
        function disPadre(){
            var dis = j(".padre").attr("disabled")
            if(dis == null){
                j(".padre").val("0");
                j(".padre").attr("disabled", "disabled");
            }
            else{
                j(".padre").removeAttr("disabled");
            }
        }
        j(".capov").value("");
    </script>


</f:subview >